package xxy.com.yangproject;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

import androidx.annotation.Nullable;

import com.blankj.utilcode.util.LogUtils;

import java.io.RandomAccessFile;
import java.lang.reflect.Field;
import java.net.HttpURLConnection;
import java.net.URL;

import xxy.com.yangproject.global.Constant;

public class TestService extends Service {
    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        LogUtils.eTag(Constant.TAG, "类名 : " + this.getClass().getName() + "\t线程ID ： " +Thread.currentThread().getId());
        //需要开启新线程，进行复杂的工作，防止界面卡顿，最终结果通过handler传递给主线程
        new Thread(new Runnable() {
            @Override
            public void run() {
                Test test = new Test();
            }
        }).start();
        try {
            for (Field field : ClassLoader.getSystemClassLoader().loadClass("Main2Activity").getFields()) {
                field.setAccessible(true);
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        return super.onStartCommand(intent, flags, startId);
    }
}
